<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Categorias</title>
        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/reset.css"/>
        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/style.css"/>
        <script type="text/javascript" src="<?php echo base_url() ?>js/jquery-1.6.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>js/validate_form.js"></script>
        <script type="text/javascript" src="<?php echo base_url() ?>js/jquery.validate.js" ></script>
        <script type="text/javascript" src="<?php echo base_url() ?>js/jquery-ui-1.8.13.custom.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>js/core.js"></script>
    </head>
    <body>
        <?php
        include ("includes/nav_bar.php");
        ?>
        <div id="main-content">
            <div id="conteudo" style="width: 65%;">
                <form action="<?php echo base_url() ?>categorias/cadastrarCategoria" method="post" class="form_cadastrarCategoria" id="form_cadastrarCategoria" style="margin-bottom: 12px;">
                    <h1>Categorias</h1>
                    <?php if(isset($view_msg)) echo $view_msg; ?>
                    <p><label class="medio" for="nome" >Titulo:</label><input type="text" name="nome" value="<?php if(isset($view_nome)) echo $view_nome; ?>" class="medio" id="nome"/></p>
                    <p style="margin-top: 2px;"><label class="medio" for="categoria" >Categoria Pai:</label><select name="id_pai" id="categoria">
                            <option value="" <?php if(!isset($view_id_pai)) echo 'selected'; ?>></option>
                            <?php foreach($view_categorias as $categoria):?>
                                <option value="<?php echo $categoria->pk_int_id; ?>" <?php if(isset($view_id_pai)) if($view_id_pai == $categoria->pk_int_id) echo 'selected'; ?>><?php echo $categoria->char_nome; ?></option>
                            <?php endforeach; ?>
                        </select></p>
                    <p><label class="medio" for="descricao" >Descrição:</label><textarea name="descricao" cols="54" rows="10" id="descricao"><?php if(isset($view_decricao)) echo $view_decricao; ?></textarea></p>
                    <p><input type="submit" name="enviar" value="Enviar" class="btn"/></p>
                </form>
                <table class="jtable">
                    <thead>
                        <tr>
                            <th>Titulo:</th>
                            <th>Descrição</th>
                            <th>Categoria Pai:</th>
                        </tr>
                    </thead>
                    <?php if(isset($view_categorias)) foreach($view_categorias as $categoria): ?>
                            <tr>
                                <td><?php echo $categoria->char_nome; ?></td>
                                <td><?php echo $categoria->char_descricao; ?></td>
                                <td><?php echo $categoria->pai; ?></td>
                            </tr>
                    <?php endforeach; ?>
                </table>
            </div>
        </div>
    </body>
</html>